package cn.vendai.com.client;


import cn.vendcommon.com.entity.InventoryItem;
import cn.vendcommon.com.entity.Machine;
import cn.vendcommon.com.entity.Result;
import cn.vendcommon.com.entity.vo.UserVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@FeignClient(name = "vend-system")
public interface SystemClient {

    /**
     * 获取用户信息
     * @return
     */
    @PostMapping("/user/userinfobyid")
    public Result<UserVO> userInfoById(@RequestParam("id") Long id);

    /**
     * 根据售卖机ID查找商品
     * @param machineId 售卖机ID
     * @return 商品列表
     */
    @GetMapping("/machine/machine/{machineId}")
    public Result<List<InventoryItem>> getInventoryByMachineId(@PathVariable int machineId);

    /**
     * 根据machineId与intelligentMap扣减库存
     * @param machineId
     * @param intelligentMap
     * @return
     */
    @PostMapping("/machine/deduct/{machineId}")
    public Result deductionInventoryByMachineId(@PathVariable int machineId, @RequestBody Map<String, Integer> intelligentMap);


    /**
     * 根据售卖机ID查找售卖机
     * @param id 售卖机ID
     * @return 售卖机
     */
    @GetMapping("/machine/{id}")
    public Result<Machine> getMachineById(@PathVariable int id);

    /**
     * 获取所有售卖机
     * @return 售卖机列表
     */
    @GetMapping("/machine")
    public Result<List<Machine>> getAllMachines();

}
